/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 马拉圈
 * Date: 2023-03-23
 * Time: 14:57
 */
public class Test2 {
    public static void main1(String[] args) throws InterruptedException {
        Object object = new Object();
        Thread thread1 = new Thread(() -> {
            while(true) {
                System.out.println("wait 前");
                synchronized (object) {
                    try {
                        object.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println("wait 后");
            }

        });
        Thread thread2 = new Thread(() -> {
            System.out.println("notify 开始");
            System.out.println(thread1.getState());
            synchronized (object) {
                System.out.println(thread1.getState());
                object.notify();
            }
            System.out.println("notify 结束");
            System.out.println(thread1.getState());
        });
        thread1.start();
        thread2.start();
    }
}
